﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using System.IO;

namespace Client.Managers
{
    class JargonMapManager
    {
        string jargonMapPath = @"config\jargonmap.ini";
        string totalDef = @"config\totalcontent.json";
        string defaultDef =@"config\defaultcontent.json";
        string userDef = @"userconfig\usercontent.json";

        Dictionary<string, string> d = new Dictionary<string, string>();
        Dictionary<string, string> jargonMap = new Dictionary<string, string>();
        JObject jo;

        public JargonMapManager()
        {
            string str = File.ReadAllText(defaultDef);
            jo = JObject.Parse(str);
            foreach (var i in jo)
            {
                d[i.Key] = (string)i.Value;
            }

            var l = IniHelper.IniHelper.ReadValues(jargonMapPath);
            foreach(KeyValuePair<string,string> i in l[0])
            {
                jargonMap[i.Key.Trim(' ')] = i.Value.Trim(' ');
            }
        }

        public string GetJargon(string str)
        {
            string t;
            if (jargonMap.TryGetValue(str, out t))
                return t;
            Console.WriteLine("术语列表中没有" + str);
            return str;
        }

        public string[] GetPanelColumns(string panelName)
        {
            var str = (string)jo[panelName];
            return str.Split(',');
        }
    }
}
